-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python & js #82
Comments
初始化二维数组const res = Array.from({ length: 10 }, () => Array.from({ length: 10 }).fill(0)); res = [[0]*10 for i in range(10)] |
mapbook_names = books.map((item) => item.name); book_names = [item["name"] for item in books]
book_names = next(map(lambda item: item["name"], books)) |
findtarget = books.find((item) => item.id === 1); // {id: 1, name: 'book1'}
target = books.find((item) => item.id === 3); // undefined target = next((item for item in books if item["id"] == 2), None) # {'id': 2, 'name': 'book2'}
target = next((item for item in books if item["id"] == 3), None) # None |
filterres = books.filter((item) => item.id === 1);
res = books.filter((item) => item.id === 3); // [] target = list(filter(lambda item: item["id"] == 1, books))
target = list(filter(lambda item: item["id"] == 3, books))
target = next(filter(lambda item: item["id"] == 1, books), [])
target = next(filter(lambda item: item["id"] == 3, books), []) |
padconst n = '10';
console.log(n.padStart(4, '*')); // **10
console.log(n.padEnd(4, '*')); // 10** n = "10"
print(n.rjust(4, "*")) # **10
print(n.ljust(4, "*")) # 10** |
CRUDnums = [1, 2, 3];
console.log(nums.push(5));
console.log(nums.pop());
console.log(nums.unshift(1));
console.log(nums.shift());
console.log(nums.splice(1, 0, 9));
console.log(nums); nums = [1, 2, 3]
print(nums.append(5))
print(nums.pop())
print(nums.insert(0, 1))
print(nums.pop(0))
print(nums.insert(1, 9))
print(nums) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python - javascript - java
init
The text was updated successfully, but these errors were encountered: