为用户构建GUI以选择他们想要运行的Python脚本。每个脚本都有自己的文档字符串来解释脚本的输入和输出。我想在他们突出显示脚本后在UI中显示该信息,但没有选择运行该脚本,并且我似乎无法从基本程序访问文档字符串。 例如。 """this is a docstring"""
print('hello world') 是 对于本例,但通常是未知的,因为它是用户在GUI中选择的内容。 # index is test.py
def on_selected(self, index):
script_path = self.tree
目前,我有一个执行以下操作的脚本。如果我有包含以下行的文本文件:
<<Name>> is at <<Location>>.
<<Name>> is feeling <<Emotion>>.
该脚本将接受此输入文件作为命令行参数,并提示用户输入变量:
Name? Bob
Location? work
Emotion? frustrated
请注意,名字只被询问一次。该脚本还接受输出文件作为参数,并将以下内容放入该文件中。
Bob is at work.
Bob is feeling frustrate
我有python脚本,我想把这个简单的脚本改成具有用户定义的输入和输出路径的.exe文件。
在下面脚本'csv‘是输入文件夹并包含多个txt文件,
import pandas as pd
import numpy as np
import os
for file in os.listdir('csv/'):
filename = 'csv/{}'.format(file)
print(filename)
df=pd.read_csv(filename)
df.to_csv(path_out)
我正在尝试运行一个Python脚本,它接受一个输入文件,操作它的内容,并将结果写入一个输出文件。
我想用引号包围每一行。目前,我创建了下面的脚本。
import sys
import re
inFile = sys.argv[1]
outFile = sys.argv[2]
with open(inFile,'r') as i:
lines = i.readlines()
def manipulate_data(lines):
content = [x.rstrip('\n') for x in lines]
res = [re
我有一个python脚本,如下所示:
#I'm treating with text files
input = str(raw_input('Name1: '))
output = str(raw_input('Name2: '))
inputFile = open(input, 'r')
outputFile = open(output, 'w')
def doSomething():
#read some lines of the input
#write some lines to the o