Python Forum
can not change double to single dash
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
can not change double to single dash
#1
python 2.7.11

def leftrotate(l, n):
    return l[n:] + l[:n]

def rightrotate(l, n):
    return l[-n:] + l[:-n]

def encode(s, k, kk):
    l = [ord(i) for i in s]
    return leftrotate(''.join([chr(i + k) for i in l]), kk)

def decode(s, k, kk):
    l = [ord(i) for i in rightrotate(s.replace("\\\\","\\"), kk)]
    return ''.join([chr(i - k) for i in l])

>>> "\\".replace("\\\\","\\")
'\\'
>>> encode("xxxxxxQ\|2",3,7)
'_\x7f5{{{{{{T'
>>>
>>> decode("_\x7f5{{{{{{T",3,7)
'xxxxxxQ\\|2'
decode error,

then i try to patch with

decode("_\x7f5{{{{{{T",3,7).replace("\\\\","\\")
but can not change double to single

>>> "\\".replace("\\\\","\\")
'\\'
Reply


Messages In This Thread
can not change double to single dash - by oco - May-27-2018, 08:40 AM
RE: can not change double to single dash - by oco - May-29-2018, 06:38 AM
RE: can not change double to single dash - by wavic - May-29-2018, 06:51 AM
RE: can not change double to single dash - by oco - May-30-2018, 07:09 AM
RE: can not change double to single dash - by wavic - May-30-2018, 07:26 AM
RE: can not change double to single dash - by oco - Jun-03-2018, 08:08 AM
RE: can not change double to single dash - by wavic - Jun-03-2018, 09:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Remove single and double quotes from a csv file in 3 to 4 column shantanu97 0 7,087 Mar-31-2021, 10:52 AM
Last Post: shantanu97
  Single digits seem to be greater than double digits Frosty_GM 4 3,600 Nov-20-2020, 10:13 AM
Last Post: DeaD_EyE
  create loop of subplot plotly dash without hardcode tonycat 0 3,967 Sep-23-2020, 08:40 AM
Last Post: tonycat
  How to update component props every time when a Dash callback returns? sguzunov 0 2,605 Jul-27-2020, 07:11 AM
Last Post: sguzunov
  Invalid archive error when attempting to install dash bootstrap components meaydemi 0 4,819 Jul-11-2019, 05:49 PM
Last Post: meaydemi
  how to use dataframe in dash? zhujp98 1 2,895 Jun-20-2018, 12:19 AM
Last Post: scidam
  dash problems zhujp98 0 2,279 Jun-14-2018, 03:30 PM
Last Post: zhujp98
  Change single element in 2D list changes every 1D element AceScottie 9 12,215 Nov-13-2017, 07:05 PM
Last Post: Larz60+
  Replace Single Backslash with Double Backslash in python saswatidas437 2 33,579 Mar-19-2017, 10:48 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020