如何在Unix环境中使用python代码提取文件
我把文件放在这里了如何在Unix环境中使用python代码提取文件,python,unix,Python,Unix,我把文件放在这里了 /home/unica/app/Affinium/Campaign/partitions/partition1/scripts/runscripts/campaigns/cnyr/dev 我想把它叫做这里 with open('/home/unica/app/Affinium/Campaign/partitions/partition1/scripts/runscripts/campaigns/cnyr/dev/CNYR_DM_TM_CAMPAIGN_WAVES.csv
/home/unica/app/Affinium/Campaign/partitions/partition1/scripts/runscripts/campaigns/cnyr/dev
我想把它叫做这里
with open('/home/unica/app/Affinium/Campaign/partitions/partition1/scripts/runscripts/campaigns/cnyr/dev/CNYR_DM_TM_CAMPAIGN_WAVES.csv','rb') as csvfile
但它将错误作为语法错误抛出。另外,如何将路径名简化为别名。尝试以下操作:
fileName = '/home/unica/app/Affinium/Campaign/partitions/partition1/scripts/runscripts/campaigns/cnyr/dev/CNYR_DM_TM_CAMPAIGN_WAVES.csv'
with open(fileName, 'rb') as csvfile: # notice that the line must end with a ':'
for line in csvfile:
# do something
或者更好地使用模块:
试试这个:
fileName = '/home/unica/app/Affinium/Campaign/partitions/partition1/scripts/runscripts/campaigns/cnyr/dev/CNYR_DM_TM_CAMPAIGN_WAVES.csv'
with open(fileName, 'rb') as csvfile: # notice that the line must end with a ':'
for line in csvfile:
# do something
或者更好地使用模块:
如果没有显示更多的代码,我想这是因为您缺少结尾冒号
:
如果没有显示更多代码,我想这是因为您缺少结尾冒号:
您缺少行尾冒号