Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Unicode string index problem
Post: RE: Unicode string index problem

(Nov-23-2019, 11:06 AM)Larz60+ Wrote: How do you say they look the same? they don'tI can't find any difference... They are equal in swift language, because swift regards they look same.
luoheng General Coding Help 6 3,112 Nov-23-2019, 03:04 PM
    Thread: Unicode string index problem
Post: RE: Unicode string index problem

(Nov-23-2019, 09:42 AM)Gribouillis Wrote: Indeed, in this string string[0] is a and string[1] is unicode U+0301 COMBINING ACUTE ACCENT. This string is different from >>> t = "\u00E1bcdefg"...
luoheng General Coding Help 6 3,112 Nov-23-2019, 10:25 AM
    Thread: Unicode string index problem
Post: Unicode string index problem

Hey, guys. I met a problem when indexing a unicode string. Here is the code: >>> string = "ábcdefg" >>> string[0] aThe index result is a, but I hope it is á. It seems the string in...
luoheng General Coding Help 6 3,112 Nov-23-2019, 03:22 AM
    Thread: Multiplication Table number margins
Post: RE: Multiplication Table number margins

This code may help you. def main(): rows = int(input("What is the upper bound of multiplication table? ")) print("The multiplication table for 2 to", rows) print() counter = 0 mult...
luoheng General Coding Help 4 2,491 Sep-18-2019, 02:00 PM
    Thread: Multiplication Table number margins
Post: RE: Multiplication Table number margins

What's the problem? The code works well. Here is an elegant way to show the table: def main(): rows = int(input("What is the upper bound of multiplication table? ")) print("The multiplication ...
luoheng General Coding Help 4 2,491 Sep-18-2019, 07:21 AM
    Thread: binary to decimal program
Post: RE: binary to decimal program

You can directly use int function to convert a binary string to decimal. x = [1, 0, 1, 0] binStr = "".join(str(i) for i in x) # convert list to str print(int(binStr, 2)) # convert binary string to dec...
luoheng Homework 3 2,010 Sep-18-2019, 01:30 AM
    Thread: Graph not plotting
Post: RE: Graph not plotting

You just defined a function, but didn't run it. def function(): # define a function pass function() # run the functionAdd svm_sgd_plot(X, Y) to your file, and you can see the graph.
luoheng General Coding Help 1 1,990 Sep-14-2019, 09:52 AM
    Thread: Pythone module for dynamic rule execution
Post: RE: Pythone module for dynamic rule execution

The answer is 1.
luoheng General Coding Help 1 9,062 Sep-13-2019, 11:25 AM
    Thread: rounding floats to a number of bits
Post: RE: rounding floats to a number of bits

>>> round(3.567, 2) # the second para is number of bits round 3.57 >>> round(3.56784, 4) 3.5678 # care with round >>> round(3.5) 4 >>> round(4.5) 4
luoheng General Coding Help 2 2,354 Sep-13-2019, 02:38 AM
    Thread: Need explain about the code
Post: RE: Need explain about the code

It's e-s, not s-e in line 34.
luoheng General Coding Help 2 1,979 Sep-12-2019, 03:10 PM
    Thread: Python .exe
Post: RE: Python .exe

Use pyinstaller.
luoheng General Coding Help 1 1,516 Sep-12-2019, 09:25 AM
    Thread: nested for loop dilemma 2
Post: RE: nested for loop dilemma 2

Replace while with if: num = int(input("Enter a number here: ")) if num >= 2: for i in range(2, num): if num % i == 0: print(num," is not a prime number.") br...
luoheng General Coding Help 12 4,996 Sep-12-2019, 09:18 AM
    Thread: FileNotFoundError: No such file or no access
Post: RE: FileNotFoundError: No such file or no access

The error is quite clear. The file C:\Users\krasona\PycharmProjects\GlioblastomaSegmentation\output\FLAIR_N4Bias.nii.gz doesn't exist, or you don't have access to it. So check if you have the file, an...
luoheng General Coding Help 2 5,010 Sep-12-2019, 07:57 AM
    Thread: a quick check for a pattern?
Post: RE: a quick check for a pattern?

You can use re to do the pattern search. Here is a example: import re pattern = re.compile(r"^(\d+)x(\d+)(?:\+(\d+))?(?:\+(\d+))?$") test = "700x400+400+200" m = pattern.match(test) print(m.groups()) ...
luoheng General Coding Help 3 2,145 Sep-12-2019, 02:03 AM
    Thread: Random Password Generator with Weird Output. Why?
Post: RE: Random Password Generator with Weird Output. W...

The problem is in Line 18 and Line 19. random_choice(random_list1) will return a element from the list. So with random_list1 = random.choice(random_list1), You have changed the random_list1 from list ...
luoheng General Coding Help 2 2,643 Sep-11-2019, 04:14 AM
    Thread: Invalid argument error thrown.
Post: RE: Invalid argument error thrown.

Line 5: change string 'url' to variable url.
luoheng General Coding Help 4 8,679 Sep-10-2019, 03:26 AM
    Thread: Manipulation a file for translation
Post: RE: Manipulation a file for translation

with open("input", encoding="utf-8") as f: with open("output", "w", encoding="utf-8") as output: output.writelines(line.split()[6] + "\n" for line in f)
luoheng General Coding Help 1 2,070 Sep-10-2019, 02:56 AM
    Thread: Hash command works differently for me in CMD and Spyder
Post: RE: Hash command works differently for me in CMD a...

The hash() may return different values for the same object on different Python implementations and Python versions. It is designed to be used only within a single Python session. So you should never r...
luoheng General Coding Help 3 2,399 Sep-10-2019, 02:40 AM
    Thread: What is the significance of end=' ' and print()
Post: RE: What is the significance of end=' ' and print(...

Another way to display matrix. x = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] for ele in x: print(*ele)
luoheng General Coding Help 4 2,486 Sep-09-2019, 03:13 PM
    Thread: update dict as per range of values
Post: RE: update dict as per range of values

You need to move the definition of dict post_details to inner loop. You always update the same dict during the loop, so the elements are same. port_details = {} # not here for first_range_port in rang...
luoheng General Coding Help 7 3,130 Sep-09-2019, 07:37 AM

User Panel Messages

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