我正在尝试制作一个鞋码来换鞋码并使用转换作为python 2.7请求中表单数据的参数
Size = raw_input('Size Number: ')
if Size=='4':
sizenumber = '530',
elif Size=='4.5':
sizenumber = '540',
elif Size=='5':
sizenumber = '550',
elif Size=='5.5':
sizenumber = '560',
elif Size=='6':
sizenumber = '570',
elif Size=='6.5':
sizenumber = '580',
elif Size=='7':
sizenumber = '590',
elif Size=='7.5':
sizenumber = '600',
elif Size=='8':
sizenumber = '610',
elif Size=='8.5':
sizenumber = '620',
elif Size=='9':
sizenumber = '630',
elif Size=='9.5':
sizenumber = '640',
elif Size=='10':
sizenumber = '650',
elif Size=='10.5':
sizenumber = '660',
elif Size=='11':
sizenumber = '670',
elif Size=='11.5':
sizenumber = '680',
elif Size=='12':
sizenumber = '690',
elif Size=='12.5':
sizenumber = '700',
elif Size=='13':
sizenumber = '710',
elif Size=='13.5':
sizenumber = '720',
elif Size=='14':
sizenumber = '730',
elif Size=='14.5':
sizenumber = '740',
elif Size=='15':
sizenumber = '750',
elif Size=='15.5':
sizenumber = '760',
elif Size=='16':
sizenumber = '770',
然后我在使用'sizenumber'
'pid':onlypid +'_'+ sizenumber
网站上的'pid'包含我设置为onlypid然后_sizenumber的产品ID,(productid_sizenumber)
我不断得到的错误是 TypeError:无法连接'str'和'tuple'对象,非常感谢任何提示或解决方案。谢谢:))
答案 0 :(得分:1)
这是错误的路线。实际上,它不会产生字符串,而是产生元组:
sizenumber = '670',
在现实生活中,你应该阅读如下:
sizenumber = ('670',)
所以实际类型是一个元组。只需删除','最后,它应该按预期工作。