Folder as python String wit \_

huangapple go评论82阅读模式
英文:

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')

huangapple
  • 本文由 发表于 2023年3月8日 16:19:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75670704.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定