我在shell脚本中有以下内容,我想将以下行转换为windows cmd文件.任何人都可以在windows cmd文件中提供与"rm"和"mv"等效的输入.
rm -f ${BUILD_ID}/${BUILD_ASIC}*rampatch*
mv ${BUILD_ID}/${BUILD_ASIC}*rampatch* ${BUILD_ID}/emul/
Run Code Online (Sandbox Code Playgroud) 我正在尝试检查id是否在列表中,并且只有当它不在列表中时使用下面的代码才附加id ...然后我看到即使id已经存在于列表中,id也会被附加..任何人都可以提供有关错误的输入?
list = ['350882 348521 350166\r\n']
id = 348521
if id not in list:
list.append(id)
print list
OUTPUT:-
['350882 348521 350166\r\n', 348521]
Run Code Online (Sandbox Code Playgroud) 我 使用下面的代码通过电子邮件发送文本文件"gerrit.txt"@ http://pastie.org/8289257的内容,但是当我查看源代码发送电子邮件后(@ http:// outlook中的电子邮件的pastie.org/8289379)我在代码中看到不必要的惊叹号(!),这会弄乱输出,任何人都可以提供输入,为什么会如此以及如何避免这种情况?
from email.mime.text import MIMEText
from smtplib import SMTP
def email (body,subject):
msg = MIMEText("%s" % body, 'html')
msg['Content-Type'] = "text/html; charset=UTF8"
msg['Subject'] = subject
s = SMTP('localhost',25)
s.sendmail('userid@company.com', ['userid2@company.com'],msg=msg.as_string())
def main ():
# open gerrit.txt and read the content into body
with open('gerrit.txt', 'r') as f:
body = f.read()
subject = "test email"
email(body,subject)
print "Done"
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud) 我试图打印orig_time为2013年6月9日,并遇到以下错误..任何人都可以提供有关此处错误的输入
码:
orig_time="2013-06-09 00:00:00"
Time=(orig_time.strftime('%m-%d-%Y'))
print Time
Run Code Online (Sandbox Code Playgroud)
错误:-
Traceback (most recent call last):
File "date.py", line 2, in <module>
Time=(orig_time.strftime('%m-%d-%Y'))
AttributeError: 'str' object has no attribute 'strftime'
Run Code Online (Sandbox Code Playgroud) 我试着检查是否有任何值"GIN"或"NOT READY"或"要放弃或需要RESUBMISSION"等于retrunVal,我注意到对于任何returnVal,"if"循环"正在"并且"INSIDE"正在获得打印,我怀疑语法不对,任何人都可以提供输入吗?
if ('GIN' or 'NOT READY' or 'TO BE ABANDON OR NEEDS RESUBMISSION' == returnVal):
print "INSIDE"
Run Code Online (Sandbox Code Playgroud) 我想删除一个文件夹,如果已经存在,有关如何删除目录的任何输入,如果它存在吗?是否有一个python等效的"rm -rf"?
如果os.path.isdir('./.repo'):shutil.rmtree('./.repo')
我试图在加入一个文件后遇到列表的某些值并遇到以下错误,如何解决这个问题的任何输入?
data_changes ={'305403': ['302180'], '312994': ['311957'], '311957': ['312621'] }
modem_changes = {'305403': [], '313113': [], '312994': ['253036', '312591'], '311957': []}
dc_set = set(data_changes)
mc_set = set(modem_changes)
with open('file.txt', 'w+') as f:
for key in dc_set.intersection(mc_set):
union_values = data_changes[key] + modem_changes[key]
values = key, ','.join(union_values)
f.write(values)
with open('file.txt', 'a') as f:
for key in dc_set.symmetric_difference(mc_set):
dc_values = data_changes.get(key) or []
mc_values = data_changes.get(key) or []
union_values = dc_values + mc_values
values=key, ','.join(union_values)
f.write(values)
Run Code Online (Sandbox Code Playgroud)
错误:-
Traceback (most recent call last):
File "final_build_list.py", …Run Code Online (Sandbox Code Playgroud) 我正在运行 shell 脚本“envsetup.sh”,但不断收到以下错误。
Badly placed ()'s
Run Code Online (Sandbox Code Playgroud)
我发现这个错误是因为我不在bash shell环境中。谁能帮忙解释一下如何进入bashshell环境吗?