我有一个文本文件,其中包含以下行: ('larry', 3, 100) 我需要使用接近我下面的方法将它的三个部分分配给不同的变量。到目前为止,我可以将其拆分,但我无法从结果中删除括号和撇号。我在stackover上尝试了其他解决方案数小时无济于事......
filecontent = filename.read().strip().split(',')
for i in filecontent:
    name = filecontent[0]
    weeks_worked = filecontent[1]
    weekly_payment = filecontent[2] 
print ("name:" + name)
print ("weeks worked:" + weeks_worked)
print ("weekly payment:" + weekly_payment)
给出结果:
名称:('拉里'
工作周数:3
每周付款:100)
我如何让它显示:
姓名:拉里
工作周数:3
每周付款:100