我有一个subject_id,它是一个动态数字。例如,它可以等于60。我手动定义了一些文件名,如下所示:x_file =“ 50.txt”x_csv_file =“ 50.csv”数字(50)可以是1或其他任何数字。有什么方法可以一次定义subject_id=50
,然后将这些名称用作x_file = "subject_id.txt"
和x_csv_file = "subject_id.txt"
?谢谢您的帮助
您可能想为此定义一个简单的功能
def file_name(subject_id):
x_file = '{}.txt'.format(subject_id)
x_csv_file = '{}.csv'.format(subject_id)
return x_file, x_csv_file