關於索引和數字判斷的小例子
## 計算使用者輸入 input內容中,索引為奇數並且and 對應的元素為數字isdigit的個數(沒有則為0)
count = 0
content = input("請輸入內容>>>>")
for i in range(len(content)):
if i % 2 == 1 and content[i].isdigit():
count = count + 1
print(count)
相關推薦
關於索引和數字判斷的小例子
## 計算使用者輸入 input內容中,索引為奇數並且and 對應的元素為數字isdigit的個數(沒有則為0)count = 0content = input("請輸入內容>>>>")for i in range(len(content)): if i % 2 == 1 and
std::mutex 和 std::lock_guard 小例子
https://blog.csdn.net/yasi_xi/article/details/19205461 參考:http://stackoverflow.com/questions/21771860/how-to-make-sure-locker-be-unlock-in-c-which-s
【mysql】mysql的內連線和外連線小例子
解釋名詞: 1、內連線(自然連線): 只有兩個表相匹配的行才能在結果集中出現 2、外連線: 包括 (1)左外連線(左邊的表不加限制) (2)右外連線(右邊的表不加限制) (3)全外連線(左右兩表都不加限制) 3、建立student、score表如下
ExecutorService和BlockingQueue的小例子
最近看了看執行緒池的內容,寫個小程式,標記下,用到了ExecutorService和BlockingQueue 需求,學校組織學生自願驗血,來了三個醫生,抽血速度依次為1000,2000,3000毫秒。 抽血屋子較小,最多能容納9個學生,即排隊,每個醫生最多排3個人。 如果
利用崑崙通態觸控式螢幕實現資料採集和邏輯判斷的例子
別小瞧國產觸控式螢幕,用得好,可以實現複雜功能,比如說資料計算、簡單邏輯、資料轉發、裝置控制,甚至能在簡單應用中省掉一套PLC。 某裝置需求:通過崑崙通態觸控式螢幕實現力值資料採集,標定,最大值計算,到位報警,後續資料計算,並列印試驗結果,初始值儲存、資料
十九、面向物件基礎1:類、__init__和__str__、小例子(烤地瓜相關程式;存放傢俱:建立了房子類、建立了床類、沙發類)
一、類和物件的關係 面向物件程式設計的2個非常重要的概念:類和物件 物件是面向物件程式設計的核心,在使用物件的過程中,為了將具有共同特徵和行為的一組物件抽象定義,提出了另外一個新的概念——類 類就
資料庫行轉列和列轉行小例子
有時候,我們想從另一個角度看一張表。這時候就會涉及行列的轉換。假如有一張成績表 mysql> select * from scores; +------+----------+-------+ | name | kemu | score | +------+-
java類載入和常量的小例子
通過下面的兩個例子簡單瞭解一下常量與類的載入的關係。 class FinalTest { static { System.out.println("static block "); } p
599. Minimum Index Sum of Two Lists兩個餐廳列表的索引和最小
ins 條件 ner 模板 還要 order PE ioc form [抄題]: Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favo
判斷dataframe是否有重複行索引或列索引和drop_duplicates用法
判斷列索引是不是重複 print(data.index.is_unique) False#表示有重複 判斷列是不是有重複 print(data.index.is_unique) False#表示有重複 drop_duplicates刪去重複資料 DataFrame.drop_duplic
輸入一串字元,並判斷其中英文字元和數字字元的個數——C語言實現(C語言練習)
先看程式執行的結果,(文末有該程式的完整程式碼) 1、先寫好框架 #include<stdio.h> void main() { } 2、再定義所需要的變數 char str;//定義一個字元型變數 str int i=0,counte
TensorFlow的一個訓練權重和偏置的小例子
import tensorflow as tf import numpy as np """ 本例子是用來演示利用TensorFlow訓練出假設的權重和偏置 """ # set data x_data = np.random.rand(100).astype(np.float32) y
【112】用python畫散點圖和直線圖的小例子
最近自學python,寫了個畫散點圖和直線圖的小例子。把這個例子放到部落格裡做個備份。 import numpy as np import matplotlib.pyplot as plt imp
React Native基礎&入門教程:以一個To Do List小例子,看props和state
本文由葡萄城技術團隊於部落格園原創並首發 轉載請註明出處:葡萄城官網,葡萄城為開發者提供專業的開發工具、解決方案和服務,賦能開發者。 在上篇中,我們介紹了什麼是Flexbox佈局,以及如何使用Flexbox佈局。還沒有看過的小夥伴歡迎回到文章列表點選檢視之前的文章瞭解。 那麼,當我們有了基本
C和Java判斷一個數字是否為素數
C: /* 素數: 素數又稱質數。所謂素數是指除了 1 和它本身以外,不能被任何整數整除的數,例如17就是素數,因為它不能被 2~16 的任一整數整除。 */ # include <stdio.h> bool PrimeNumber(int val); int ma
flume 的安裝和入門小例子
本文結構 我的環境 CentOS 7 flume 安裝與啟動 flume 的avro小例子 Spool 的小例子 Syslogtcp 小例子 1. flume 安裝與啟動 1.1 下載安裝包 訪問官網傳送門,不信你不點下載apache-fl
Java 小例子:通過 Socket 傳送和接收檔案
這是一個簡單的包含傳送端和接收端的例子。傳送端向接收端傳送檔名和檔案內容,接收端將收到的檔案儲存在磁碟上。接收端可以同時接收多個傳送端傳來的檔案,但沒有處理檔案同名的情況。 這個例子中設計了一個簡單的協議。傳送的內容是這樣的: 檔名長度(4位元組)—檔名—檔案內容長度(4位
利用springmvc和jdbcTemplate搭建一個對資料庫操作的小例子
在接觸到struts2+hibernate+spring三大框架搭建的專案時覺得對於比較簡單的專案會顯得很繁重,特別是struts現在使用的也不是很廣泛,所以我通過網上的部分資料以及對spring的一些瞭解,在maven下搭建一個springmvc的小程式,僅僅是對資料庫的
一個小例子分清sizeof(s)和strlrn(s)的區別
一、sizeof sizeof(...)是運算子,在標頭檔案中typedef為unsigned int,其值在編譯時即計算好了,引數可以是陣列、指標、型別、物件、函式等。它的功能是:獲得保證能容納實現所建立的最大物件的位元組大小。由於在編譯時計算,因此sizeof不
在MongoDB中建立一個索引而效能提升1000倍的小例子
在https://www.cnblogs.com/xuliuzai/p/9965229.html的博文中我們介紹了MongoDB的常見索引的建立語法。部分同學還想看看MongoDB的威力到底有多大,所以,在這兒追加一個例子,感受一下索引的效能。 通過在某一欄位上建立索引,從優化前的執行15.15S到優化後降