英文:
Folder as python String wit \_
问题
I want to print a foldername as a Python 3.9 string.
It looks like
print(r'C:\ABC\DEF\_GHI')
It works generally. BUT:
I need to print it in Jira as an issue comment. There it unfortunately looks like this:
C:\ABC\DEF_GHI
I use the default JIRA API for Python
from jira.client import JIRA
jiraConnection = JIRA(basic_auth=(self.username, self.password), options=self.options)
jiraConnection.add_comment(issueID, r'C:\ABC\DEF\_GHI')
Result: C:\ABC\DEF_GHI
I did try:
r''
Result: C:\ABC\DEF_GHI
'C:\\ABC\\DEF\\_GHI'
Result:
C:\ABC\DEF
_GHI
'C:\\ABC\\DEF\\\_GHI'
Result:
C:\ABC\DEF_GHI
英文:
i want to print a foldername as a python 3.9 string.
It looks like
C:\ABC\DEF\_GHI
When i use
print(r'C:\ABC\DEF\_GHI')
it works generally. BUT:
I need to print it in Jira as a issue comment. There it unfortunately looks like this:
C:\ABC\DEF_GHI
I use the default JIRA API for python
from jira.client import JIRA
jiraConnection = JIRA(basic_auth=(self.username, self.password), options=self.options)
jiraConnection.add_comment(issueID,r'C:\ABC\DEF\_GHI')
Result: C:\ABC\DEF_GHI
i did try:
r''
Result: C:\ABC\DEF_GHI
'C:\\ABC\\DEF\\_GHI'
Result:
C:\ABC\DEF
_GHI
'C:\\ABC\\DEF\\\_GHI'
Result:
C:\ABC\DEF_GHI
答案1
得分: 0
尝试使用r
前缀的双反斜杠:
jiraConnection.add_comment(issueID, r'C:\\ABC\\DEF\\_GHI')
或者如果双反斜杠仍然不起作用,可以使用正斜杠:
jiraConnection.add_comment(issueID, 'C:/ABC/DEF/_GHI')
英文:
Try double backslashes with r
prefix:
jiraConnection.add_comment(issueID, r'C:\\ABC\\DEF\\_GHI')
or forward slashes if double backslashes still not working:
jiraConnection.add_comment(issueID, 'C:/ABC/DEF/_GHI')
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论