现在增加几个类型,如果是微博weibo商品,它传的字符串是;“微任务直发 :1 微任务转发:2 直发:3转发 :4” 微信wechat商品传的是“头条:1 二条: 2” 头条headLine商品"浦发价:1" 小红书hongshu商品"平台图文价: 1 平台视频价: 2 普发图文价: 3 普发视频价 : 4 供稿图文价:5 " 抖音douyin商品”星图20s:1 星图60s :2 星图60s+ : 3 普发20s: 4 普发60s :5 普发60s+:6 星图直播价:7 直播价:8“ 其他other"推荐价: 1 普发价:2" 现在要求根据商品不同,传的字符串也不同,按照字符串截取,并且按照数量顺序,填写道fdSalesPrice 这个字段按照数量多少fdSalesPrice1,fdSalesPrice2最多到fdSalesPrice8 如果没按照上述字符串填写,返回需错误信息需要按照上述类型填写
时间: 2024-03-30 12:38:46 浏览: 135
flat-weibo::snowman_selector:这是一个使微博网页版更纯净的Chrome插件
好的,根据您的要求,我可以给出以下代码实现:
```
# 假设商品类型为weibo,传入的字符串为s
s = "微任务直发 :1 微任务转发:2 直发:3转发 :4"
if "微任务直发" in s:
fdSalesPrice1 = "微任务直发"
if "微任务转发" in s:
fdSalesPrice2 = "微任务转发"
if "直发" in s:
fdSalesPrice3 = "直发"
if "转发" in s:
fdSalesPrice4 = "转发"
# 如果传入的字符串不符合要求,则返回错误信息
if not any([fdSalesPrice1, fdSalesPrice2, fdSalesPrice3, fdSalesPrice4]):
print("请按照规定格式填写字符串")
# 如果商品类型为wechat,传入的字符串为s
s = "头条:1 二条: 2"
if "头条" in s:
fdSalesPrice1 = "头条"
if "二条" in s:
fdSalesPrice2 = "二条"
# 如果商品类型为headLine,传入的字符串为s
s = "浦发价:1"
if "浦发价" in s:
fdSalesPrice1 = "浦发价"
# 如果商品类型为hongshu,传入的字符串为s
s = "平台图文价: 1 平台视频价: 2 普发图文价: 3 普发视频价 : 4 供稿图文价:5 "
if "平台图文价" in s:
fdSalesPrice1 = "平台图文价"
if "平台视频价" in s:
fdSalesPrice2 = "平台视频价"
if "普发图文价" in s:
fdSalesPrice3 = "普发图文价"
if "普发视频价" in s:
fdSalesPrice4 = "普发视频价"
if "供稿图文价" in s:
fdSalesPrice5 = "供稿图文价"
# 如果商品类型为douyin,传入的字符串为s
s = "星图20s:1 星图60s :2 星图60s+ : 3 普发20s: 4 普发60s :5 普发60s+:6 星图直播价:7 直播价:8"
if "星图20s" in s:
fdSalesPrice1 = "星图20s"
if "星图60s" in s:
fdSalesPrice2 = "星图60s"
if "星图60s+" in s:
fdSalesPrice3 = "星图60s+"
if "普发20s" in s:
fdSalesPrice4 = "普发20s"
if "普发60s" in s:
fdSalesPrice5 = "普发60s"
if "普发60s+" in s:
fdSalesPrice6 = "普发60s+"
if "星图直播价" in s:
fdSalesPrice7 = "星图直播价"
if "直播价" in s:
fdSalesPrice8 = "直播价"
# 如果商品类型为other,传入的字符串为s
s = "推荐价: 1 普发价:2"
if "推荐价" in s:
fdSalesPrice1 = "推荐价"
if "普发价" in s:
fdSalesPrice2 = "普发价"
```
在这个代码中,我们先根据商品类型和传入的字符串进行判断,然后将字符串截取出来,并填写到fdSalesPrice1到fdSalesPrice8这些字段中。如果传入的字符串不符合要求,则会返回错误信息。
阅读全文